package com.hyb.i18n.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.AbstractResourceBasedMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;

@RestController
public class IndexController {

	@Autowired
	private LanguageUtil languageUtil;

	@RequestMapping("/getMsg")
	public String getMsg(String msgCode) {
		return languageUtil.getMessageByCode(msgCode );
	}

	@RequestMapping("/getCurrentLanguage")
	public String getCurrentLanguage() {
		return languageUtil.getCurrentLanguage();
	}

	@RequestMapping("/setLanguage")
	public String setLanguage(String language) {
		languageUtil.setLanguage(language);
		return "success";
	}
}
